package LC;

/**
 * @ClassName Lc413
 * @Description: TODO
 * @Author hl
 * @Date 2020/8/11
 * @Version V1.0
 **/
public class Lc413 {
    public int numberOfArithmeticSlices(int[] A) {
        if(A==null||A.length==0){
            return 0;
        }
        int []dp=new int[A.length];
        for(int i=2;i<A.length;i++){
            if(A[i]-A[i-1]==A[i-1]-A[i-2]){
                dp[i]=dp[i-1]+1;
            }
        }
        int sum=0;
        for(int cnt:dp){
            sum=sum+cnt;
        }
       return  sum;
    }
}
